package com.zhixi.pattern.notimportant.mediatorpattern.operation;

/**
 * 库存
 *
 * @作者 ShuHaoNan
 * @邮箱 shuhaonan1@gmail.com
 * @时间 2020/11/17 9:07
 */
public class Stock extends AbstractColleague {

    public Stock(AbstractMediator mediator) {
        super(mediator);
        System.out.println("初始化库存为100台电脑");
    }

    private static int computerNumber = 100;

    /**
     * 库存增加
     */
    public void increase(int number) {
        computerNumber += number;
        System.out.println("库存增加数量为" + computerNumber);
    }

    /**
     * 库存减少
     */
    public void decrease(int number) {
        computerNumber -= number;
        System.out.println("库存减少数量为" + computerNumber);
    }

    /**
     * 获取库存数量
     */
    public int getStockNumber() {
        return computerNumber;
    }

    /**
     * 库存太多，通知销售人员尽快销售，采购人员停止采购
     */
    public void clearStock() {
        System.out.println("清理存货数量为" + computerNumber);
        super.mediator.execute("stock.clear");
    }

}
